<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function fun(){
				let xhr =new XMLHttpRequest()
				xhr.open("GET","data.txt",true)
				xhr.send()
				xhr.onreadystatechange=function(){
				if (xhr.readyState == 4&&xhr.status==200) {
					let data=xhr.responseText
					document.querySelector("span").innerHTML=data
				} 
			}
		}
		</script>
	</head>
	<body>
		请求到的数据是:<span></span><br>
		<button type="button" onclick="fun()">请求</button>
	</body>
</html>
